//
//  PageControl.h
//  YiXiProject
//
//  Created by iMac on 2019/8/1.
//  Copyright © 2019 iMac. All rights reserved.
//

#import "CardViews.h"

@implementation CardViews

-(UIImageView *)currentImg
{
    if(!_currentImg)
    {
        _currentImg = [[UIImageView alloc]initWithFrame:self.bounds];
        _currentImg.backgroundColor = ColorAlphe(245, 245, 245, 1);
        _currentImg.layer.cornerRadius = 10;
        _currentImg.layer.masksToBounds = YES;
    }
    return _currentImg;
}

-(UILabel *)likeImg
{
    if(!_likeImg)
    {
        _likeImg = [[UILabel alloc] initWithFrame:CGRectMake(15, 50, 125, 60)];
        _likeImg.layer.cornerRadius = 3;
        _likeImg.layer.masksToBounds = YES;
        _likeImg.layer.borderWidth = 5;
        _likeImg.layer.borderColor = [UIColor colorWithRed:205/255.0 green:92/255.0 blue:92/255.0 alpha:1].CGColor;
        _likeImg.text = @"Like";
        _likeImg.textAlignment = NSTextAlignmentCenter;
        _likeImg.font = HeiTiFont(40);
        _likeImg.textColor = [UIColor colorWithRed:205/255.0 green:92/255.0 blue:92/255.0 alpha:1];
        _likeImg.alpha = 0;
    }
    return _likeImg;
}

-(UILabel *)disLikeImg
{
    if(!_disLikeImg)
    {
        _disLikeImg = [[UILabel alloc] initWithFrame:CGRectMake(self.frame.size.width-140, 50, 125, 60)];
        _disLikeImg.layer.cornerRadius = 3;
        _disLikeImg.layer.masksToBounds = YES;
        _disLikeImg.layer.borderWidth = 5;
        _disLikeImg.layer.borderColor = [UIColor colorWithRed:205/255.0 green:92/255.0 blue:92/255.0 alpha:1].CGColor;
        _disLikeImg.text = @"pass";
        _disLikeImg.textAlignment = NSTextAlignmentCenter;
        _disLikeImg.font = HeiTiFont(40);
        _disLikeImg.textColor = [UIColor colorWithRed:205/255.0 green:92/255.0 blue:92/255.0 alpha:1];
        _disLikeImg.alpha = 0;
    }
    return _disLikeImg;
}

-(UILabel *)nameLabel
{
    if(!_nameLabel)
    {
        _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, self.frame.size.height-110, self.frame.size.width-100, 40)];
        _nameLabel.textColor = [UIColor whiteColor];
        _nameLabel.text = @"page";
        _nameLabel.font = FontCustom(35, 1);
    }
    return _nameLabel;
}

-(UILabel *)jobLabel
{
    if(!_jobLabel)
    {
        _jobLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, self.frame.size.height-60, self.frame.size.width-100, 40)];
        _jobLabel.textColor = [UIColor whiteColor];
        _jobLabel.text = @"18  教育";
        _jobLabel.font = [UIFont systemFontOfSize:25];
    }
    return _jobLabel;
}

-(UIButton *)infoButton
{
    if(!_infoButton)
    {
        _infoButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        _infoButton.frame = CGRectMake(self.frame.size.width-70, self.frame.size.height-75, 36, 36);
        [_infoButton setTitle:@"i" forState:UIControlStateNormal];
        _infoButton.titleLabel.font = HeiTiFont(28);
        [_infoButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [_infoButton setBackgroundColor:[UIColor whiteColor]];
        _infoButton.layer.cornerRadius = 18;
        _infoButton.layer.masksToBounds = YES;
    }
    return _infoButton;
}

-(instancetype)initWithFrame:(CGRect)frame
{
    if(self = [super initWithFrame:frame])
    {
        [self addSubview:self.currentImg];
        [self addSubview:self.nameLabel];
        [self addSubview:self.jobLabel];
        [self addSubview:self.infoButton];
        [self addSubview:self.likeImg];
        [self addSubview:self.disLikeImg];
    }
    return self;
}


-(void)installHomeDicDatas:(NSDictionary *)dic
{
    [self.currentImg sd_setImageWithURL:[NSURL URLWithString:dic[@"photo"]] placeholderImage:nil];
    self.nameLabel.text = dic[@"user_name"];
    self.jobLabel.text = dic[@"user_work"];
}

//-(void)installHomeArrData:(NSString *)str
//{
//    self.currentImg.image = [UIImage imageNamed:str];
//}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
